package no.weather;

import java.util.Date;
import java.util.List;

import android.location.Location;

public class WeatherStation {
	private Date deliverFrom;
	private Date deliverTo;
	private String id;
	private Boolean isFavorite = false;
	private Location location;
	private List<WeatherType> mTypes;
	private String name;
	private String provider;

	// Seconds
	private Double refressRate;

	private Boolean typesIsKnown = false;

	public Date getDeliverFrom() {
		return deliverFrom;
	}

	public Date getDeliverTo() {
		return deliverTo;
	}

	public String getId() {
		return id;
	}

	public Boolean getIsFavorite() {
		return isFavorite;
	}

	public Location getLocation() {
		return location;
	}

	public String getName() {
		return name;
	}

	public String getProvider() {
		return provider;
	}

	public Double getRefressRate() {
		return refressRate;
	}

	public List<WeatherType> getTypes() {
		return mTypes;
	}

	public String getTypesCodes() {
		if (mTypes.size() == 0)
			return null;
		String s = mTypes.get(0).getCode();
		for (int i = 1; i < mTypes.size(); i++) {
			s += "," + mTypes.get(i).getCode();
		}
		return s;
	}

	public Boolean getTypesIsKnown() {
		return typesIsKnown;
	}

	public Boolean hasAllTypes(List<WeatherType> types) {
		if (types == null)
			return true;

		for (WeatherType type : types) {
			Boolean hasType = false;
			for (WeatherType mType : mTypes) {
				if (type.getCode().equals(mType.getCode())) {
					hasType = true;
					break;
				}
			}
			if (!hasType)
				return false;
		}
		return true;
	}

	public void setDeliverFrom(Date deliverFrom) {
		this.deliverFrom = deliverFrom;
	}

	public void setDeliverTo(Date date) {
		deliverTo = date;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setIsFavorite(Boolean isFavorite) {
		this.isFavorite = isFavorite;
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setProvider(String provider) {
		this.provider = provider;
	}

	public void setRefressRate(Double refressRate) {
		this.refressRate = refressRate;
	}

	public void setTypes(List<WeatherType> types) {
		typesIsKnown = true;
		mTypes = types;
	}

	public void setTypesIsKnown(Boolean typesIsKnown) {
		this.typesIsKnown = typesIsKnown;
	}

}
